package com.jorado.redis.extend;

public enum JoradoNodeState {
    //
    NORMAL(""),
    //
    PFAIL("fail?"),
    //
    FAIL("fail");
    //
    private String state;

    JoradoNodeState(String state) {
        this.state = state;
    }

    public static JoradoNodeState findNodeStateByName(String state) {
        if (state != null) {
            String stateLowerCase = state.toLowerCase();
            if (stateLowerCase.contains(PFAIL.state)) {
                return PFAIL;
            } else if (stateLowerCase.contains(FAIL.state)) {
                return FAIL;
            }
        }
        return NORMAL;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }
}
